package com.seiko.danmaku.di

import com.seiko.danmaku.engine.internal.DanmakuEngineOptions
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import master.flame.danmaku.danmaku.model.BaseDanmaku
import master.flame.danmaku.danmaku.model.IDisplayer
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object DanmaModule {

    @Provides
    @Singleton
    fun provideDanmakuEngineOptions(): DanmakuEngineOptions {
        return DanmakuEngineOptions {
            setDanmakuStyle(IDisplayer.DANMAKU_STYLE_STROKEN, 2.5f)
            // 设置是否禁止重叠
            val overlappingEnablePair = java.util.HashMap<Int, Boolean>()
            overlappingEnablePair[BaseDanmaku.TYPE_SCROLL_RL] = true
            overlappingEnablePair[BaseDanmaku.TYPE_FIX_TOP] = true
//            //设置防弹幕重叠
            preventOverlapping(overlappingEnablePair)
            //合并重复弹幕
            isDuplicateMergingEnabled = false
            //弹幕滚动速度
            setScrollSpeedFactor(1.2f)
            //弹幕文字大小
//            setScaleTextSize(1.2f)
            //弹幕文字透明度
            setDanmakuTransparency(0.9f)
            // 是否显示滚动弹幕
            r2LDanmakuVisibility = true
            // 是否显示顶部弹幕
            ftDanmakuVisibility = true
            // 是否显示底部弹幕
            fbDanmakuVisibility = false
            // 同屏数量限制
            setMaximumVisibleSizeInScreen(0)
            val maxLines = HashMap<Int, Int>()
            maxLines[BaseDanmaku.TYPE_FIX_TOP] = 5
            maxLines[BaseDanmaku.TYPE_SCROLL_RL] = 5
            maxLines[BaseDanmaku.TYPE_SCROLL_LR] = 5
            maxLines[BaseDanmaku.TYPE_FIX_BOTTOM] = 5
            setMaximumLines(maxLines)

            setDanmakuMargin(8)
        }
    }

}